package com.generator.demo.utils.generatorUtil;


/**
 * @author hujunyu
 * @create 2021/8/16
 * 数据库配置文件
 **/
public class GeneratorProperties {
    //模块
    private String moduleName = "";
    //父包
    private String parentPackage;
    //数据库地址
    private String url;
    //用户名
    private String user;
    //密码
    private String password;
    //驱动
    private String driver;
    //是否覆盖
    private Boolean fileOverride = false;
    //创建人
    private String createUser;
    //数据库表名前缀
    private String tablePrefix;
    //mybatisPlus默认模板路径
    private String templatePath = "/templates/mybatisDefault/mapper.xml.ftl";
    //实体包
    private String entityPackage = ".entity";
    //mapper包
    private String mapperPackage = ".mapper";
    //service包
    private String servicePackage = ".service";
    //impl包
    private String serviceImplPackage = ".service.impl";


    public GeneratorProperties() {

    }

    public String getModuleName() {
        return moduleName;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public String getParentPackage() {
        if (parentPackage == null || parentPackage == "") {
            throw new RuntimeException("父包不能为空!");
        }
        return parentPackage;
    }

    public void setParentPackage(String parentPackage) {
        this.parentPackage = parentPackage;
    }

    public String getUrl() {
        if (url == null || url == "") {
            throw new RuntimeException("数据库地址不能为空!");
        }
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUser() {
        if (user == null || user == "") {
            throw new RuntimeException("数据库用户不能为空！");
        }
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPassword() {
        if (password == null || password == "") {
            throw new RuntimeException("数据库密码不能为空！");
        }
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getDriver() {
        if (driver == null || driver == "") {
            throw new RuntimeException("数据库驱动不能为空！");
        }
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }

    public Boolean getFileOverride() {
        return fileOverride;
    }

    public void setFileOverride(Boolean fileOverride) {
        this.fileOverride = fileOverride;
    }

    public String getCreateUser() {
        if (createUser == null || createUser == "") {
            throw new RuntimeException("创建人不能为空!");
        }
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public String getTablePrefix() {
        if (tablePrefix == null || tablePrefix == "") {
            throw new RuntimeException("表名前缀不能为空!");
        }
        return tablePrefix;
    }

    public void setTablePrefix(String tablePrefix) {
        this.tablePrefix = tablePrefix;
    }

    public String getEntityPackage() {
        return tablePrefix + entityPackage;
    }

    public void setEntityPackage(String entityPackage) {
        this.entityPackage = entityPackage;
    }

    public String getMapperPackage() {
        return tablePrefix + mapperPackage;
    }

    public void setMapperPackage(String mapperPackage) {
        this.mapperPackage = mapperPackage;
    }

    public String getServicePackage() {
        return tablePrefix + servicePackage;
    }

    public void setServicePackage(String servicePackage) {
        this.servicePackage = servicePackage;
    }

    public String getServiceImplPackage() {
        return tablePrefix + serviceImplPackage;
    }

    public void setServiceImplPackage(String serviceImplPackage) {
        this.serviceImplPackage = tablePrefix + serviceImplPackage;
    }

    public String getTemplatePath() {
        return templatePath;
    }

    public void setTemplatePath(String templatePath) {
        this.templatePath = templatePath;
    }

    @Override
    public String toString() {
        return "GeneratorProperties{" +
                "moduleName='" + moduleName + '\'' +
                ", parentPackage='" + parentPackage + '\'' +
                ", url='" + url + '\'' +
                ", user='" + user + '\'' +
                ", password='" + password + '\'' +
                ", driver='" + driver + '\'' +
                ", fileOverride=" + fileOverride +
                ", createUser='" + createUser + '\'' +
                ", tablePrefix='" + tablePrefix + '\'' +
                ", templatePath='" + templatePath + '\'' +
                ", entityPackage='" + entityPackage + '\'' +
                ", mapperPackage='" + mapperPackage + '\'' +
                ", servicePackage='" + servicePackage + '\'' +
                ", serviceImplPackage='" + serviceImplPackage + '\'' +
                '}';
    }
}
